package ngames.com.sushitv.action;

import android.app.Activity;
import android.app.Application;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;

import ngames.com.sushitv.AppApplication;
import ngames.com.sushitv.Fragment.SearchFragment;
import ngames.com.sushitv.Fragment.SearchPromptFragment;
import ngames.com.sushitv.base.BaseListAction;
import ngames.com.sushitv.core.ModelCallback;
import ngames.com.sushitv.entity.SearchPrompt;
import ngames.com.sushitv.interfaces.ChangFragment;
import ngames.com.sushitv.interfaces.TransmitSearchPrompt;
import ngames.com.sushitv.view.ClearEditText;

/**
 * Created by Fearless on 2016/8/5.
 */
public class SearchAction extends BaseListAction {
    private ClearEditText clearEditText;
    private Button cancelBtn;
    private SearchFragment fragment;
    private ChangFragment changef;
    public SearchAction(Activity activity, View baseView, ChangFragment changef) {
        super(activity, baseView);
        this.changef=changef;
        AppApplication.setChangFragment(changef);
    }


    @Override
    public void onRefreshData() {

    }

    @Override
    public void loadMore() {

    }

    public SearchPrompt searchPrompt(String s) {
        final SearchPrompt[] searchPrompt = {new SearchPrompt()};
        getAppModel().searchPrompt(s, "video_titles", new ModelCallback<ArrayList<String>>() {
            @Override
            public void onBeforeRequest(String urlTag) {

            }

            @Override
            public void onSuccess(ArrayList<String> data) {
                Log.e("ok","ok");
                changef.ChangeFragment(2);
            }

            @Override
            public void onFailure(String errorEvent, String message) {

            }
        },new TransmitSearchPrompt() {
            @Override
            public void transmitSearchPrompt(SearchPrompt searchPrompt) {
               /* SearchPromptFragment sp=new SearchPromptFragment();
                sp.transmitSearchPrompt(searchPrompt);*/
                //AppApplication.setSearchPrompt(searchPrompt);

            }
        });

        return searchPrompt[0];
    }



}
